package com.example.vfu_telia;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;

public class CanvasView extends View {

	Paint paint = new Paint();
	Paint squarePaint = new Paint();
	Paint crossPaint = new Paint();
	int bars;

	public CanvasView(Context context, int x) {
		super(context);
		bars = x;

		paint.setStrokeWidth(80);
		paint.setColor(Color.argb(255, 101, 45, 134));
		
		squarePaint.setStrokeWidth(5);
		squarePaint.setColor(Color.argb(200, 101, 45, 134));
		squarePaint.setStyle(Paint.Style.STROKE);
		
		crossPaint.setStrokeWidth(50);
		crossPaint.setColor(Color.argb(255, 216, 0, 0));
	}

	@Override
	protected void onDraw(android.graphics.Canvas canvas) {
		// TODO Auto-generated method stub
		super.onDraw(canvas);

		canvas.drawColor(Color.WHITE);
		canvas.drawRect(170, 560, 250, 615, squarePaint);
		canvas.drawRect(280, 490, 360, 615, squarePaint);
		canvas.drawRect(390, 420, 470, 615, squarePaint);
		canvas.drawRect(500, 350, 580, 615, squarePaint);
		canvas.drawRect(610, 280, 690, 615, squarePaint);
		canvas.drawRect(720, 210, 800, 615, squarePaint);
		canvas.drawRect(830, 140, 910, 615, squarePaint);
		
		
		
		
		
		if (bars <= 10 && bars != 0){
			canvas.drawLine(210, 615, 210, 560, paint);			
		}

		if (bars <= 20 && bars >= 10) {
			canvas.drawLine(210, 615, 210, 560, paint);
			canvas.drawLine(320, 615, 320, 490, paint);
		}

		if (bars <= 30 && bars >= 20) {
			canvas.drawLine(210, 615, 210, 560, paint);
			canvas.drawLine(320, 615, 320, 490, paint);
			canvas.drawLine(430, 615, 430, 420, paint);
		}
		
		if (bars <= 40 && bars >= 30 ){
			canvas.drawLine(210, 615, 210, 560, paint);
			canvas.drawLine(320, 615, 320, 490, paint);
			canvas.drawLine(430, 615, 430, 420, paint);
			canvas.drawLine(540, 615, 540, 350, paint);
		}
		
		if(bars <= 50 && bars >= 40){
			canvas.drawLine(210, 615, 210, 560, paint);
			canvas.drawLine(320, 615, 320, 490, paint);
			canvas.drawLine(430, 615, 430, 420, paint);
			canvas.drawLine(540, 615, 540, 350, paint);
			canvas.drawLine(650, 615, 650, 280, paint);
		}
		
		if ( bars <= 60 && bars >= 50){
			canvas.drawLine(210, 615, 210, 560, paint);
			canvas.drawLine(320, 615, 320, 490, paint);
			canvas.drawLine(430, 615, 430, 420, paint);
			canvas.drawLine(540, 615, 540, 350, paint);
			canvas.drawLine(650, 615, 650, 280, paint);
			canvas.drawLine(760, 615, 760, 210, paint);
		}
		
		if (bars <= 70 && bars >= 60){
			canvas.drawLine(210, 615, 210, 560, paint);
			canvas.drawLine(320, 615, 320, 490, paint);
			canvas.drawLine(430, 615, 430, 420, paint);
			canvas.drawLine(540, 615, 540, 350, paint);
			canvas.drawLine(650, 615, 650, 280, paint);
			canvas.drawLine(760, 615, 760, 210, paint);
			canvas.drawLine(870, 615, 870, 140, paint);
			
		}
		if(bars == 0) {
			canvas.drawLine(220, 580, 860, 180, crossPaint);
			canvas.drawLine(220, 180, 860, 580, crossPaint);
			
		}
	}
}
